<template>
  <view>
    <view class="search-container" :style="{ 'background-color': bgColor }" @click="searchHandler">
      <view class="search-box" :style="{ 'border-radius': radius + 'px' }">
        <uni-icons type="search" size="18"></uni-icons>
        <text class="placeholder">搜索</text>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  name: 'my-search',
  // 封装自定义组件的自定义属性
  props:{
    bgColor:{
      type:String,
      default:'#f80633'
    },
    radius:{
      type:Number,
      default:18
    }
  },
  data() {
    return {};
  },
  methods:{
    // 模拟输入框，自定义事件
    searchHandler(){
      this.$emit('click')
    }
  }
};
</script>

<style lang="scss">
.search-container {
  height: 50px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  .search-box {
    background-color: #ffffff;
    height: 36px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    .placeholder {
      margin-left: 5px;
      font-size: 15px;
    }
  }
}
</style>
